//
//  PBVerifyInfoController.m
//  PBHomeDemo
//
//  Created by Playboy on 2018/1/12.
//  Copyright © 2018年 tmkj. All rights reserved.
//

#import "PBVerifyInfoController.h"
#import "PBVerifyInfoCell.h"

static NSString * const kPBVerifyInfoCell = @"PBVerifyInfoCell";

@interface PBVerifyInfoController ()<UITableViewDelegate,UITableViewDataSource,PBVerifyInfoCellDelegate>
@property (strong, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSMutableDictionary *paramDic;

@end

@implementation PBVerifyInfoController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self configure];
}
- (void)configure {
    [self configureView];
    [self configureData];
}

- (void)configureView {
    [self.tableView registerNib:[UINib nibWithNibName:kPBVerifyInfoCell bundle:nil] forCellReuseIdentifier:kPBVerifyInfoCell];
}
- (void)configureData {
    
}

#pragma mark - <UITableViewDelegate,UITableViewDataSource>
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PBVerifyInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:kPBVerifyInfoCell forIndexPath:indexPath];
    cell.jumpVC = self;
    cell.delegate = self;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 650;
}

#pragma mark - PBVerifyInfoCellDelegate
- (void)backWithValue:(NSString *)value key:(NSString *)key {
    [self.paramDic setValue:value forKey:key];
    NSLog(@"%@",self.paramDic);
}

// 提交认证
- (IBAction)commitButtonClick:(UIButton *)sender {

    if (self.paramDic.count < 4) {
        [self showHint:@"请完善全部信息"];
        return;
    }
    
    [TMNetwork requestPostWithParam:[self.paramDic copy] url:@"/user/identifyCard" callback:^(TMBaseReqModel *model) {
        if (model.code == 200) {
            [self showHint:@"资料提交成功，请耐心等待"];
            [self.navigationController popViewControllerAnimated:YES];
        }else {
            [self showHint:model.message];
        }
    }];
}

- (NSMutableDictionary *)paramDic {
    if (!_paramDic) {
        _paramDic = [[NSMutableDictionary alloc] init];
    }
    return _paramDic;
}


#pragma mark - super
- (void)resetNavigationBarItems {
    [super resetNavigationBarItems];
    self.title = @"实名认证";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
